using UnityEngine;
using System.Collections;
namespace Framework {
    public class ColorChangerVertex : MonoBehaviour {

        Mesh mesh;
        Color[] meshColors;

        void Start() {
            mesh = GetComponent<MeshFilter>().mesh;
            meshColors = new Color[mesh.vertexCount];
        }

        // Update is called once per frame
        void Update() {
            for (int i = 0; i < meshColors.Length; ++i) {
                float offset = mesh.vertices[i].magnitude;
                float r = Mathf.Abs( Mathf.Sin( Time.timeSinceLevelLoad ) );
                float g = 0;
                float b = 0;
                Color newColor = new Color( r, g, b );

                meshColors[i] = newColor;
            }
            mesh.colors = meshColors;

        }

    }
}